if (Meteor.isServer) { 
  //系统内置默认选项
  Meteor.publish('default_options', function () {
      return DefaultOptions.find({});
  });
}
// 一些内置选项
if(DefaultOptions.find().count() === 0){
  // 默认部门
  DefaultOptions.insert({
    name:'部门',
    value_set: [
      {name:'总经部'},
      {name:'人力资源部'},
      {name:'采购部'},
      {name:'行政部'},
      {name:'财务部'},
      {name:'门店'},
      {name:'柜组'},
      {name:'销售部'},
      {name:'售后服务部'},
      {name:'仓库'},
      {name:'自定义'}
    ]
  });

  // 默认职能
  DefaultOptions.insert({
    name:'职能',
    value_set: [
      {name:'老板',pmsn_group_name:'boss',belong:'总经办'},
      {name:'会计',pmsn_group_name:'accounting',belong:'财务部'},
      {name:'仓管',pmsn_group_name:'warehouse-keeper',belong:'仓库'},
      {name:'店长',pmsn_group_name:'store-manager',belong:'门店'},
      {name:'销售员',pmsn_group_name:'seller',belong:'门店'},
      {name:'收银员',pmsn_group_name:'cashier',belong:'门店'}
    ]
  });

  DefaultOptions.insert({
    name:'默认分类',
    value_set: [{
      cid: 'Mobile',
      name:'手机',
      properties: {
        'brand':{
          field_type:'select',
          name:'品牌',
          value_set: [
            {name:'三星',logo:'samsung'},
            {name:'苹果',logo:'apple'},
            {name:'小米',logo:'xiaomi'},
            {name:'魅族',logo:'meizu'},
            {name:'乐视',logo:'letv'},
            {name:'HTC',logo:'htc'},
            {name:'酷派',logo:'coolpad'},
            {name:'联想',logo:'lenovo'},
            {name:'OPPO',logo:'oppo'},
            {name:'华为',logo:'huawei'},
            {name:'VIVO',logo:'vivo'},
            {name:'锤子',logo:'smartisan'},
            {name:'中兴',logo:'zte'},
            {name:'奇酷',logo:'qiku'},
            {name:'索尼',logo:'sony'}
          ]
        },
        'model':{
          field_type:'input',
          name:'型号',
        },
        'color':{
          field_type:'select',
          name:'颜色',
          value_set:[
            {name:'白色',rgb:'#fefefe'},
            {name:'黑色',rgb:'#222'},
            {name:'灰色',rgb:'#666'},
            {name:'银色',rgb:'#e1e1e1'},
            {name:'金色',rgb:'#FFD700'},
            {name:'红色',rgb:'#e41318'},
            {name:'粉色',rgb:'#f79'},
            {name:'橙色',rgb:'#ea641a'},
            {name:'黄色',rgb:'#fff306'},
            {name:'绿色',rgb:'#7eda33'},
            {name:'青色',rgb:'#2dddf5'},
            {name:'蓝色',rgb:'#1277e9'},
            {name:'紫色',rgb:'#b21392'}
          ]
        },
        'memoInside':{
          field_type:'select',
          name:'机身内存',
          value_set:[{name:'512M'},{name:'1G'},{name:'2G'},
          {name:'4G'},{name:'8G'},{name:'16G'},{name:'32G'},
          {name:'64G'},{name:'128G'},{name:'256G'}]
        },
        'memoCard':{
          field_type:'select',
          name:'存储卡',
          value_set:[{name:'512M'},{name:'1G'},{name:'2G'},
          {name:'4G'},{name:'8G'},{name:'16G'},{name:'32G'},
          {name:'64G'},{name:'128G'},{name:'256G'}]
        },
        'netType':{
          field_type:'select',
          name:'网络',
          value_set: [{name:'移动4G'},{name:'联通4G'},{name:'电信4G'},
          {name:'移动3G'},{name:'联通3G'},{name:'电信3G'},
          {name:'移动2G/联通2G'},{name:'电信2G'},{name:'双卡'}]
        },
        'version':{
          field_type:'select',
          name:'版本',
          value_set:[{name:'国行'},{name:'港版'},{name:'欧版'}]
        }
      },
      // 固定参数
      extend_properties:[ ]
    },{
      cid: 'PrepaidCard',
      name:'充值卡',
    },{
      cid: 'Accessory',
      name:'手机配件',
    },{
        cid: 'Battery',
        name:'电池',
        parent_id: 'Accessory'
      },{
        cid: 'ChargerPal',
        name:'充电宝',
        parent_id: 'Accessory'
      },{
        cid: 'PowerAdapter',
        name:'充电器',
        parent_id: 'Accessory'
      },{
        cid: 'Earplugs',
        name:'耳机/耳塞',
        parent_id: 'Accessory'
      },{
        cid: 'SDCard',
        name:'存储卡',
        parent_id: 'Accessory'
      },{
        cid: 'DataCable',
        name:'数据线',
        parent_id: 'Accessory'
      },{
        cid: 'Case',
        name:'手机壳',
        parent_id: 'Accessory'
      },{
        cid: 'Protective',
        name:'贴膜/保护膜',
        parent_id: 'Accessory'
      },{
        cid: 'SportsPackage',
        name:'运动臂包',
        parent_id: 'Accessory'
      },{
        cid: 'SelfieStick',
        name:'自拍杆',
        parent_id: 'Accessory'
      },{
        cid: 'Stylus',
        name:'触控笔',
        parent_id: 'Accessory'
      },{
        cid: 'Camera',
        name:'手机镜头',
        parent_id: 'Accessory'
      }
    ]
  });

  // 默认颜色
  DefaultOptions.insert({
    name:'颜色',
    value_set: [
      {name:'白色',rgb:'#fefefe'},
      {name:'黑色',rgb:'#222'},
      {name:'灰色',rgb:'#666'},
      {name:'银色',rgb:'#e1e1e1'},
      {name:'金色',rgb:'#FFD700'},
      {name:'红色',rgb:'#e41318'},
      {name:'粉色',rgb:'#f79'},
      {name:'橙色',rgb:'#ea641a'},
      {name:'黄色',rgb:'#fff306'},
      {name:'绿色',rgb:'#7eda33'},
      {name:'青色',rgb:'#2dddf5'},
      {name:'蓝色',rgb:'#1277e9'},
      {name:'紫色',rgb:'#b21392'}
    ]
  });
  // 内存容量
  DefaultOptions.insert({
    name:'内存',
    value_set: ['512M','1G','2G','4G','8G','16G','32G','64G','128G','256G']
  });
  //网络制式
  DefaultOptions.insert({
    name:'网络',
    value_set: ['移动4G','联通4G','电信4G','移动3G','联通3G','电信3G','移动2G/联通2G','电信2G','双卡','全网通']
  });

  //商品品牌 TODO 
  DefaultOptions.insert({
    name:'品牌',
    value_set: [{name:'三星',logo:'samsung'},
      {name:'苹果',logo:'apple'},
      {name:'小米',logo:'xiaomi'},
      {name:'魅族',logo:'meizu'},
      {name:'乐视',logo:'letv'},
      {name:'HTC',logo:'htc'},
      {name:'酷派',logo:'coolpad'},
      {name:'联想',logo:'lenovo'},
      {name:'OPPO',logo:'oppo'},
      {name:'华为',logo:'huawei'},
      {name:'VIVO',logo:'vivo'},
      {name:'锤子',logo:'smartisan'},
      {name:'中兴',logo:'zte'},
      {name:'奇酷',logo:'qiku'},
      {name:'索尼',logo:'sony'}
    ]
  });

}
